<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="UTF-8" xml:lang="en">
	<head>
		<!-- change this to the title you want to appear in browser title bar -->
		<title>Nami-Koma's App Engine Home</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="author" content="dreamLogic" />
		<meta name="description" content=" " />
		<link rel="stylesheet" href="<%=path%>/resources/css/style.css" type="text/css" />
		<LINK href="<%=path%>/resources/images/bug.ico" type=image/x-icon rel="shortcut icon" />
	</head>
	<body>
		<div id="wrap">
			<div id="header"></div>
			<div id="title">
				Version 1.0
			</div>
			<div id="container">
				<div class="content">
					<!-- here is your page content -->
					<h3>
						Visitors List
					</h3>
					<table width="100%" style="BORDER-COLLAPSE: collapse; border-color: #666666" cellPadding="1" align="center" border="1">
						<tr style="background-color: #FFDAB9;" align="center">
							<th width="10%">No.</th>
							<th width="25%" style="cursor: pointer;" onclick="orderby('ip')">IP</th>
							<th width="30%" style="cursor: pointer;" onclick="orderby('address')">Address</th>
							<th width="25%" style="cursor: pointer;" onclick="orderby('visitDate')">Date</th>
							<th width="10%">Edit</th>
						</tr>
						<c:choose>
							<c:when test="${not empty visitorList}">
								<c:forEach var="visitor" items="${visitorList}" varStatus="status">
									<tr align="center">
										<td>${status.index + 1}</td>
										<td>${visitor.ip}</td>
										<td>${visitor.address}</td>
										<td>${visitor.visitDate}</td>
										<td>
											<a href="<%=path%>/admin/VisitorServlet?method=delete&id=${visitor.id}">Delete</a>
										</td>
									</tr>
								</c:forEach>
							</c:when>
							<c:otherwise>
								<tr>
									<td colspan="3">There are no visitors...</td>
								</tr>
							</c:otherwise>
						</c:choose>
					</table>
					<p>&nbsp;</p>
				</div>
				<div id="footer">
					<img src="http://code.google.com/appengine/images/appengine-silver-120x30.gif" alt="由 Google App Engine 提供支持" />
					<br />
					<a href="mailto:java-koma@gmail.com">Contact Us</a>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="#">Copyright ©2010 Nami & Koma. All Rights Reserved.</a>
				</div>
				<form id="orderForm" action="<%=path%>/admin/VisitorServlet" method="POST">
					<input type="hidden" id="oldOrder" name="oldOrder" value="${order}" />
					<input type="hidden" id="order" name="order" />
				</form>
			</div>
		</div>
	</body>
<script>
function orderby(newOrderBy)
{
	var oldOrder = document.getElementById("oldOrder").value;
	if(oldOrder && oldOrder != "" && oldOrder.length > 0)
	{
		if(newOrderBy == oldOrder)
		{
			newOrderBy = newOrderBy + " desc";
		}
	}
	document.getElementById("order").value = newOrderBy;
	document.getElementById("orderForm").submit();
}
</script>
</html>